<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>配置 Eslint</title>
    <meta name="description" content="A VitePress Site">
    <link rel="preload stylesheet" href="/init/assets/style.0316f3b9.css" as="style">
    
    <script type="module" src="/init/assets/app.d88a8da6.js"></script>
    <link rel="preload" href="/init/assets/inter-roman-latin.2ed14f66.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/init/assets/chunks/framework.1a8a81da.js">
    <link rel="modulepreload" href="/init/assets/chunks/theme.831ec444.js">
    <link rel="modulepreload" href="/init/assets/project-config_vue_eslint.md.b98da907.lean.js">
    <link rel="icon" href="/init/favicon.ico">
    <script id="check-dark-light">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-71011c1a><!--[--><!--]--><!--[--><span tabindex="-1" data-v-eca4131c></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-eca4131c> Skip to content </a><!--]--><!----><header class="VPNav" data-v-71011c1a data-v-93cc4d3f><div class="VPNavBar has-sidebar" data-v-93cc4d3f data-v-a63be76e><div class="container" data-v-a63be76e><div class="title" data-v-a63be76e><div class="VPNavBarTitle has-sidebar" data-v-a63be76e data-v-597d53dc><a class="title" href="/init/" data-v-597d53dc><!--[--><!--]--><!--[--><img class="VPImage logo" src="/init/vite.svg" alt data-v-d0446525><!--]--><!--[-->项目初始化环境配置<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-a63be76e><div class="curtain" data-v-a63be76e></div><div class="content-body" data-v-a63be76e><!--[--><!--]--><div class="VPNavBarSearch search" style="--vp-meta-key:&#39;Meta&#39;;" data-v-a63be76e><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-a63be76e data-v-c3057263><span id="main-nav-aria-label" class="visually-hidden" data-v-c3057263>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/init/start/index.html" tabindex="0" data-v-c3057263 data-v-99b04806><!--[--><span data-v-99b04806>开始</span><!--]--></a><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-c3057263 data-v-6ab1da6f><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-6ab1da6f><span class="text" data-v-6ab1da6f><!----><span data-v-6ab1da6f>项目环境配置</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-6ab1da6f><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-6ab1da6f><div class="VPMenu" data-v-6ab1da6f data-v-83bfd49c><div class="items" data-v-83bfd49c><!--[--><!--[--><div class="VPMenuGroup" data-v-83bfd49c data-v-60b2921d><!----><!--[--><!--[--><div class="VPMenuLink" data-v-60b2921d data-v-59eab3fb><a class="VPLink link" href="/init/project-config/vue/create.html" data-v-59eab3fb><!--[-->vue<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-60b2921d data-v-59eab3fb><a class="VPLink link" href="/init/project-config/uniapp/create.html" data-v-59eab3fb><!--[-->uniapp<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-60b2921d data-v-59eab3fb><a class="VPLink link" href="/init/project-config/react/create.html" data-v-59eab3fb><!--[-->react<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-60b2921d data-v-59eab3fb><a class="VPLink link" href="/init/project-config/react-native/create.html" data-v-59eab3fb><!--[-->react native<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/init/skill/index.html" tabindex="0" data-v-c3057263 data-v-99b04806><!--[--><span data-v-99b04806>小技巧</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-a63be76e data-v-189112e2><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-189112e2 data-v-bb9b0e56 data-v-817dcc84><span class="check" data-v-817dcc84><span class="icon" data-v-817dcc84><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-bb9b0e56><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-bb9b0e56><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-a63be76e data-v-b2c4fa23 data-v-f1334b01><!--[--><a class="VPSocialLink no-icon" href="https://gitee.com/HikJ" aria-label="github" target="_blank" rel="noopener" data-v-f1334b01 data-v-7edb934f><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="..." aria-label target="_blank" rel="noopener" data-v-f1334b01 data-v-7edb934f></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-a63be76e data-v-73e792d7 data-v-6ab1da6f><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-6ab1da6f><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-6ab1da6f><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-6ab1da6f><div class="VPMenu" data-v-6ab1da6f data-v-83bfd49c><!----><!--[--><!--[--><!----><div class="group" data-v-73e792d7><div class="item appearance" data-v-73e792d7><p class="label" data-v-73e792d7>Appearance</p><div class="appearance-action" data-v-73e792d7><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-73e792d7 data-v-bb9b0e56 data-v-817dcc84><span class="check" data-v-817dcc84><span class="icon" data-v-817dcc84><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-bb9b0e56><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-bb9b0e56><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="group" data-v-73e792d7><div class="item social-links" data-v-73e792d7><div class="VPSocialLinks social-links-list" data-v-73e792d7 data-v-f1334b01><!--[--><a class="VPSocialLink no-icon" href="https://gitee.com/HikJ" aria-label="github" target="_blank" rel="noopener" data-v-f1334b01 data-v-7edb934f><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="..." aria-label target="_blank" rel="noopener" data-v-f1334b01 data-v-7edb934f></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-a63be76e data-v-2f3c18a6><span class="container" data-v-2f3c18a6><span class="top" data-v-2f3c18a6></span><span class="middle" data-v-2f3c18a6></span><span class="bottom" data-v-2f3c18a6></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav reached-top" data-v-71011c1a data-v-a1da7c63><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a1da7c63><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-a1da7c63><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-a1da7c63>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a1da7c63 data-v-f59df57b><button data-v-f59df57b>Return to top</button><!----></div></div><aside class="VPSidebar" data-v-71011c1a data-v-8b047d0b><div class="curtain" data-v-8b047d0b></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-8b047d0b><span class="visually-hidden" id="sidebar-aria-label" data-v-8b047d0b> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-8b047d0b><section class="VPSidebarItem level-0 collapsible has-active" data-v-8b047d0b data-v-e8d6fac0><div class="item" role="button" tabindex="0" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><h2 class="text" data-v-e8d6fac0>vue</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-e8d6fac0><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-e8d6fac0><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-e8d6fac0><!--[--><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/create.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>创建项目</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/elementPlus.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Element-Plus配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/env.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>环境变量别名设置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/axios.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Axios的二次封装</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/scss.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Scss变量自动导入</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/src.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Src别名设置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/eslint.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Eslint配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/prettier.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Prettier配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/husky.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Husky配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/commitlint.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Commitlint配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/constraint.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>强制使用pnpm包管理工具</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/svg.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Svg图标的使用</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/proxy.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Proxy代理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e8d6fac0 data-v-e8d6fac0><div class="item" data-v-e8d6fac0><div class="indicator" data-v-e8d6fac0></div><a class="VPLink link link" href="/init/project-config/vue/pinia.html" data-v-e8d6fac0><!--[--><p class="text" data-v-e8d6fac0>Pinia持久化</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-71011c1a data-v-a1ff5652><div class="VPDoc has-sidebar has-aside" data-v-a1ff5652 data-v-d46edd38><!--[--><!--]--><div class="container" data-v-d46edd38><div class="aside" data-v-d46edd38><div class="aside-curtain" data-v-d46edd38></div><div class="aside-container" data-v-d46edd38><div class="aside-content" data-v-d46edd38><div class="VPDocAside" data-v-d46edd38 data-v-e9864b31><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" role="navigation" data-v-e9864b31 data-v-cc4ac93a><div class="content" data-v-cc4ac93a><div class="outline-marker" data-v-cc4ac93a></div><div class="outline-title" role="heading" data-v-cc4ac93a>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-cc4ac93a><span class="visually-hidden" id="doc-outline-aria-label" data-v-cc4ac93a> Table of Contents for current page </span><ul class="root" data-v-cc4ac93a data-v-1f2d64fa><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-e9864b31></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-d46edd38><div class="content-container" data-v-d46edd38><!--[--><!--]--><!----><main class="main" data-v-d46edd38><div style="position:relative;" class="vp-doc _init_project-config_vue_eslint" data-v-d46edd38><div><h1 id="配置-eslint" tabindex="-1">配置 Eslint <a class="header-anchor" href="#配置-eslint" aria-label="Permalink to &quot;配置 Eslint&quot;">​</a></h1><h2 id="安装" tabindex="-1">安装 <a class="header-anchor" href="#安装" aria-label="Permalink to &quot;安装&quot;">​</a></h2><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#B392F0;">pnpm</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">i</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint</span><span style="color:#E1E4E8;"> </span><span style="color:#79B8FF;">-D</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#6F42C1;">pnpm</span><span style="color:#24292E;"> </span><span style="color:#032F62;">i</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint</span><span style="color:#24292E;"> </span><span style="color:#005CC5;">-D</span></span></code></pre></div><p>同时 <strong>Vscode</strong> 也需安装 <strong>eslint</strong> 插件</p><p>生成配置文件: .eslintrc.cjs</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#B392F0;">npx</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint</span><span style="color:#E1E4E8;"> </span><span style="color:#79B8FF;">--init</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#6F42C1;">npx</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint</span><span style="color:#24292E;"> </span><span style="color:#005CC5;">--init</span></span></code></pre></div><h2 id="eslintrc-cjs-配置文件" tabindex="-1">.eslintrc.cjs 配置文件 <a class="header-anchor" href="#eslintrc-cjs-配置文件" aria-label="Permalink to &quot;.eslintrc.cjs 配置文件&quot;">​</a></h2><div class="language-js vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#6A737D;">// @see https://eslint.bootcss.com/docs/rules/</span></span>
<span class="line"></span>
<span class="line"><span style="color:#79B8FF;">module</span><span style="color:#E1E4E8;">.</span><span style="color:#79B8FF;">exports</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">=</span><span style="color:#E1E4E8;"> {</span></span>
<span class="line"><span style="color:#E1E4E8;">	env: {</span></span>
<span class="line"><span style="color:#E1E4E8;">		browser: </span><span style="color:#79B8FF;">true</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		es2021: </span><span style="color:#79B8FF;">true</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		node: </span><span style="color:#79B8FF;">true</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		jest: </span><span style="color:#79B8FF;">true</span></span>
<span class="line"><span style="color:#E1E4E8;">	},</span></span>
<span class="line"><span style="color:#E1E4E8;">	</span><span style="color:#6A737D;">/* 指定如何解析语法 */</span></span>
<span class="line"><span style="color:#E1E4E8;">	parser: </span><span style="color:#9ECBFF;">&#39;vue-eslint-parser&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">	</span><span style="color:#6A737D;">/** 优先级低于 parse 的语法解析配置 */</span></span>
<span class="line"><span style="color:#E1E4E8;">	parserOptions: {</span></span>
<span class="line"><span style="color:#E1E4E8;">		ecmaVersion: </span><span style="color:#9ECBFF;">&#39;latest&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		sourceType: </span><span style="color:#9ECBFF;">&#39;module&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		parser: </span><span style="color:#9ECBFF;">&#39;@typescript-eslint/parser&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		jsxPragma: </span><span style="color:#9ECBFF;">&#39;React&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		ecmaFeatures: {</span></span>
<span class="line"><span style="color:#E1E4E8;">			jsx: </span><span style="color:#79B8FF;">true</span></span>
<span class="line"><span style="color:#E1E4E8;">		}</span></span>
<span class="line"><span style="color:#E1E4E8;">	},</span></span>
<span class="line"><span style="color:#E1E4E8;">	</span><span style="color:#6A737D;">/* 继承已有的规则 */</span></span>
<span class="line"><span style="color:#E1E4E8;">	extends: [</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;eslint:recommended&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;plugin:vue/vue3-essential&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;plugin:@typescript-eslint/recommended&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;plugin:prettier/recommended&#39;</span></span>
<span class="line"><span style="color:#E1E4E8;">	],</span></span>
<span class="line"><span style="color:#E1E4E8;">	plugins: [</span><span style="color:#9ECBFF;">&#39;vue&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#9ECBFF;">&#39;@typescript-eslint&#39;</span><span style="color:#E1E4E8;">],</span></span>
<span class="line"><span style="color:#E1E4E8;">	</span><span style="color:#6A737D;">/*</span></span>
<span class="line"><span style="color:#6A737D;">	 * &quot;off&quot; 或 0    ==&gt;  关闭规则</span></span>
<span class="line"><span style="color:#6A737D;">	 * &quot;warn&quot; 或 1   ==&gt;  打开的规则作为警告（不影响代码执行）</span></span>
<span class="line"><span style="color:#6A737D;">	 * &quot;error&quot; 或 2  ==&gt;  规则作为一个错误（代码不能执行，界面报错）</span></span>
<span class="line"><span style="color:#6A737D;">	 */</span></span>
<span class="line"><span style="color:#E1E4E8;">	rules: {</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#6A737D;">// eslint（https://eslint.bootcss.com/docs/rules/）</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;no-var&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;error&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 要求使用 let 或 const 而不是 var</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;no-multiple-empty-lines&#39;</span><span style="color:#E1E4E8;">: [</span><span style="color:#9ECBFF;">&#39;warn&#39;</span><span style="color:#E1E4E8;">, { max: </span><span style="color:#79B8FF;">1</span><span style="color:#E1E4E8;"> }], </span><span style="color:#6A737D;">// 不允许多个空行</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;no-console&#39;</span><span style="color:#E1E4E8;">: p<wbr>rocess.env.</span><span style="color:#79B8FF;">NODE_ENV</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">===</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">&#39;production&#39;</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">?</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">&#39;error&#39;</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">:</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;no-debugger&#39;</span><span style="color:#E1E4E8;">: p<wbr>rocess.env.</span><span style="color:#79B8FF;">NODE_ENV</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">===</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">&#39;production&#39;</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">?</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">&#39;error&#39;</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">:</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;no-unexpected-multiline&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;error&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 禁止空余的多行</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;no-useless-escape&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 禁止不必要的转义字符</span></span>
<span class="line"></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#6A737D;">// typeScript (https://typescript-eslint.io/rules)</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;@typescript-eslint/no-unused-vars&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;error&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 禁止定义未使用的变量</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;@typescript-eslint/prefer-ts-expect-error&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;error&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 禁止使用 @ts-ignore</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;@typescript-eslint/no-explicit-any&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 禁止使用 any 类型</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;@typescript-eslint/no-non-null-assertion&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;@typescript-eslint/no-namespace&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 禁止使用自定义 TypeScript 模块和命名空间。</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;@typescript-eslint/semi&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#6A737D;">// eslint-plugin-vue (https://eslint.vuejs.org/rules/)</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;vue/multi-word-component-names&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 要求组件名称始终为 “-” 链接的单词</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;vue/script-setup-uses-vars&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;error&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 防止&lt;script setup&gt;使用的变量&lt;template&gt;被标记为未使用</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;vue/no-mutating-props&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;">, </span><span style="color:#6A737D;">// 不允许组件 prop的改变</span></span>
<span class="line"><span style="color:#E1E4E8;">		</span><span style="color:#9ECBFF;">&#39;vue/attribute-hyphenation&#39;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&#39;off&#39;</span><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// 对模板中的自定义组件强制执行属性命名样式</span></span>
<span class="line"><span style="color:#E1E4E8;">	}</span></span>
<span class="line"><span style="color:#E1E4E8;">}</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#6A737D;">// @see https://eslint.bootcss.com/docs/rules/</span></span>
<span class="line"></span>
<span class="line"><span style="color:#005CC5;">module</span><span style="color:#24292E;">.</span><span style="color:#005CC5;">exports</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">=</span><span style="color:#24292E;"> {</span></span>
<span class="line"><span style="color:#24292E;">	env: {</span></span>
<span class="line"><span style="color:#24292E;">		browser: </span><span style="color:#005CC5;">true</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		es2021: </span><span style="color:#005CC5;">true</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		node: </span><span style="color:#005CC5;">true</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		jest: </span><span style="color:#005CC5;">true</span></span>
<span class="line"><span style="color:#24292E;">	},</span></span>
<span class="line"><span style="color:#24292E;">	</span><span style="color:#6A737D;">/* 指定如何解析语法 */</span></span>
<span class="line"><span style="color:#24292E;">	parser: </span><span style="color:#032F62;">&#39;vue-eslint-parser&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">	</span><span style="color:#6A737D;">/** 优先级低于 parse 的语法解析配置 */</span></span>
<span class="line"><span style="color:#24292E;">	parserOptions: {</span></span>
<span class="line"><span style="color:#24292E;">		ecmaVersion: </span><span style="color:#032F62;">&#39;latest&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		sourceType: </span><span style="color:#032F62;">&#39;module&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		parser: </span><span style="color:#032F62;">&#39;@typescript-eslint/parser&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		jsxPragma: </span><span style="color:#032F62;">&#39;React&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		ecmaFeatures: {</span></span>
<span class="line"><span style="color:#24292E;">			jsx: </span><span style="color:#005CC5;">true</span></span>
<span class="line"><span style="color:#24292E;">		}</span></span>
<span class="line"><span style="color:#24292E;">	},</span></span>
<span class="line"><span style="color:#24292E;">	</span><span style="color:#6A737D;">/* 继承已有的规则 */</span></span>
<span class="line"><span style="color:#24292E;">	extends: [</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;eslint:recommended&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;plugin:vue/vue3-essential&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;plugin:@typescript-eslint/recommended&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;plugin:prettier/recommended&#39;</span></span>
<span class="line"><span style="color:#24292E;">	],</span></span>
<span class="line"><span style="color:#24292E;">	plugins: [</span><span style="color:#032F62;">&#39;vue&#39;</span><span style="color:#24292E;">, </span><span style="color:#032F62;">&#39;@typescript-eslint&#39;</span><span style="color:#24292E;">],</span></span>
<span class="line"><span style="color:#24292E;">	</span><span style="color:#6A737D;">/*</span></span>
<span class="line"><span style="color:#6A737D;">	 * &quot;off&quot; 或 0    ==&gt;  关闭规则</span></span>
<span class="line"><span style="color:#6A737D;">	 * &quot;warn&quot; 或 1   ==&gt;  打开的规则作为警告（不影响代码执行）</span></span>
<span class="line"><span style="color:#6A737D;">	 * &quot;error&quot; 或 2  ==&gt;  规则作为一个错误（代码不能执行，界面报错）</span></span>
<span class="line"><span style="color:#6A737D;">	 */</span></span>
<span class="line"><span style="color:#24292E;">	rules: {</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#6A737D;">// eslint（https://eslint.bootcss.com/docs/rules/）</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;no-var&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;error&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 要求使用 let 或 const 而不是 var</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;no-multiple-empty-lines&#39;</span><span style="color:#24292E;">: [</span><span style="color:#032F62;">&#39;warn&#39;</span><span style="color:#24292E;">, { max: </span><span style="color:#005CC5;">1</span><span style="color:#24292E;"> }], </span><span style="color:#6A737D;">// 不允许多个空行</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;no-console&#39;</span><span style="color:#24292E;">: p<wbr>rocess.env.</span><span style="color:#005CC5;">NODE_ENV</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">===</span><span style="color:#24292E;"> </span><span style="color:#032F62;">&#39;production&#39;</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">?</span><span style="color:#24292E;"> </span><span style="color:#032F62;">&#39;error&#39;</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">:</span><span style="color:#24292E;"> </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;no-debugger&#39;</span><span style="color:#24292E;">: p<wbr>rocess.env.</span><span style="color:#005CC5;">NODE_ENV</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">===</span><span style="color:#24292E;"> </span><span style="color:#032F62;">&#39;production&#39;</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">?</span><span style="color:#24292E;"> </span><span style="color:#032F62;">&#39;error&#39;</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">:</span><span style="color:#24292E;"> </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;no-unexpected-multiline&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;error&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 禁止空余的多行</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;no-useless-escape&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 禁止不必要的转义字符</span></span>
<span class="line"></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#6A737D;">// typeScript (https://typescript-eslint.io/rules)</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;@typescript-eslint/no-unused-vars&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;error&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 禁止定义未使用的变量</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;@typescript-eslint/prefer-ts-expect-error&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;error&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 禁止使用 @ts-ignore</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;@typescript-eslint/no-explicit-any&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 禁止使用 any 类型</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;@typescript-eslint/no-non-null-assertion&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;@typescript-eslint/no-namespace&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 禁止使用自定义 TypeScript 模块和命名空间。</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;@typescript-eslint/semi&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">,</span></span>
<span class="line"></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#6A737D;">// eslint-plugin-vue (https://eslint.vuejs.org/rules/)</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;vue/multi-word-component-names&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 要求组件名称始终为 “-” 链接的单词</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;vue/script-setup-uses-vars&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;error&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 防止&lt;script setup&gt;使用的变量&lt;template&gt;被标记为未使用</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;vue/no-mutating-props&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;">, </span><span style="color:#6A737D;">// 不允许组件 prop的改变</span></span>
<span class="line"><span style="color:#24292E;">		</span><span style="color:#032F62;">&#39;vue/attribute-hyphenation&#39;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&#39;off&#39;</span><span style="color:#24292E;"> </span><span style="color:#6A737D;">// 对模板中的自定义组件强制执行属性命名样式</span></span>
<span class="line"><span style="color:#24292E;">	}</span></span>
<span class="line"><span style="color:#24292E;">}</span></span></code></pre></div><h2 id="vue3-环境代码校验插件" tabindex="-1">Vue3 环境代码校验插件 <a class="header-anchor" href="#vue3-环境代码校验插件" aria-label="Permalink to &quot;Vue3 环境代码校验插件&quot;">​</a></h2><p>相关说明</p><div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#E1E4E8;"># 让所有与prettier规则存在冲突的Eslint rules失效，并使用prettier进行代码检查</span></span>
<span class="line"><span style="color:#9ECBFF;">&quot;eslint-config-prettier&quot;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#9ECBFF;">&quot;eslint-plugin-import&quot;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#9ECBFF;">&quot;eslint-plugin-node&quot;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#9ECBFF;">&quot;eslint-plugin-vue&quot;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;"># 运行更漂亮的Eslint，使prettier规则优先级更高，Eslint优先级低</span></span>
<span class="line"><span style="color:#9ECBFF;">&quot;eslint-plugin-prettier&quot;</span><span style="color:#E1E4E8;">,</span></span>
<span class="line"><span style="color:#E1E4E8;"># 该解析器允许使用Eslint校验所有babel code</span></span>
<span class="line"><span style="color:#9ECBFF;">&quot;@babel/eslint-parser&quot;</span><span style="color:#E1E4E8;">,</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292E;"># 让所有与prettier规则存在冲突的Eslint rules失效，并使用prettier进行代码检查</span></span>
<span class="line"><span style="color:#032F62;">&quot;eslint-config-prettier&quot;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#032F62;">&quot;eslint-plugin-import&quot;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#032F62;">&quot;eslint-plugin-node&quot;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#032F62;">&quot;eslint-plugin-vue&quot;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;"># 运行更漂亮的Eslint，使prettier规则优先级更高，Eslint优先级低</span></span>
<span class="line"><span style="color:#032F62;">&quot;eslint-plugin-prettier&quot;</span><span style="color:#24292E;">,</span></span>
<span class="line"><span style="color:#24292E;"># 该解析器允许使用Eslint校验所有babel code</span></span>
<span class="line"><span style="color:#032F62;">&quot;@babel/eslint-parser&quot;</span><span style="color:#24292E;">,</span></span></code></pre></div><p>安装指令</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#B392F0;">pnpm</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">install</span><span style="color:#E1E4E8;"> </span><span style="color:#79B8FF;">-D</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint-plugin-vue</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint-plugin-import</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint-plugin-node</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint-plugin-prettier</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint-config-prettier</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">eslint-plugin-node</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">@babel/eslint-parser</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#6F42C1;">pnpm</span><span style="color:#24292E;"> </span><span style="color:#032F62;">install</span><span style="color:#24292E;"> </span><span style="color:#005CC5;">-D</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint-plugin-vue</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint-plugin-import</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint-plugin-node</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint-plugin-prettier</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint-config-prettier</span><span style="color:#24292E;"> </span><span style="color:#032F62;">eslint-plugin-node</span><span style="color:#24292E;"> </span><span style="color:#032F62;">@babel/eslint-parser</span></span></code></pre></div><h2 id="创建-eslintignore-忽略文件" tabindex="-1">创建 .eslintignore 忽略文件 <a class="header-anchor" href="#创建-eslintignore-忽略文件" aria-label="Permalink to &quot;创建 .eslintignore 忽略文件&quot;">​</a></h2><blockquote><p>添加如下文件</p></blockquote><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#e1e4e8;">dist</span></span>
<span class="line"><span style="color:#e1e4e8;">node_modules</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292e;">dist</span></span>
<span class="line"><span style="color:#24292e;">node_modules</span></span></code></pre></div><h2 id="添加运行脚本" tabindex="-1">添加运行脚本 <a class="header-anchor" href="#添加运行脚本" aria-label="Permalink to &quot;添加运行脚本&quot;">​</a></h2><div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki github-dark has-diff vp-code-dark"><code><span class="line"><span style="color:#9ECBFF;">&quot;scripts&quot;</span><span style="color:#E1E4E8;">: {</span></span>
<span class="line"><span style="color:#E1E4E8;">    </span><span style="color:#6A737D;">// ...</span></span>
<span class="line diff add"><span style="color:#E1E4E8;">    </span><span style="color:#79B8FF;">&quot;lint&quot;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&quot;eslint src&quot;</span><span style="color:#E1E4E8;">,   </span></span>
<span class="line diff add"><span style="color:#E1E4E8;">    </span><span style="color:#79B8FF;">&quot;fix&quot;</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">&quot;eslint src --fix&quot;</span><span style="color:#E1E4E8;">,    </span></span>
<span class="line"><span style="color:#E1E4E8;">}</span></span></code></pre><pre class="shiki github-light has-diff vp-code-light"><code><span class="line"><span style="color:#032F62;">&quot;scripts&quot;</span><span style="color:#24292E;">: {</span></span>
<span class="line"><span style="color:#24292E;">    </span><span style="color:#6A737D;">// ...</span></span>
<span class="line diff add"><span style="color:#24292E;">    </span><span style="color:#005CC5;">&quot;lint&quot;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&quot;eslint src&quot;</span><span style="color:#24292E;">,   </span></span>
<span class="line diff add"><span style="color:#24292E;">    </span><span style="color:#005CC5;">&quot;fix&quot;</span><span style="color:#24292E;">: </span><span style="color:#032F62;">&quot;eslint src --fix&quot;</span><span style="color:#24292E;">,    </span></span>
<span class="line"><span style="color:#24292E;">}</span></span></code></pre></div><p>通过 <code>pnpm run lint</code> 去检测语法，如果出现不规范格式,通过 <code>pnpm run fix</code> 修改，如果你已经安装了 <code>ESlint</code> 和 <code>Error Lens</code> 插件的话，你可能并不需要这一脚本，因为在编写代码时就会有实时的校验，方便进行不规范的修改</p></div></div></main><footer class="VPDocFooter" data-v-d46edd38 data-v-fa7cebd8><!--[--><!--]--><div class="edit-info" data-v-fa7cebd8><div class="edit-link" data-v-fa7cebd8><a class="VPLink link vp-external-link-icon no-icon edit-link-button" href="https://gitee.com/HikJ/vitepress-template" target="_blank" rel="noreferrer" data-v-fa7cebd8><!--[--><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="edit-link-icon" aria-label="edit icon" data-v-fa7cebd8><path d="M18,23H4c-1.7,0-3-1.3-3-3V6c0-1.7,1.3-3,3-3h7c0.6,0,1,0.4,1,1s-0.4,1-1,1H4C3.4,5,3,5.4,3,6v14c0,0.6,0.4,1,1,1h14c0.6,0,1-0.4,1-1v-7c0-0.6,0.4-1,1-1s1,0.4,1,1v7C21,21.7,19.7,23,18,23z"></path><path d="M8,17c-0.3,0-0.5-0.1-0.7-0.3C7,16.5,6.9,16.1,7,15.8l1-4c0-0.2,0.1-0.3,0.3-0.5l9.5-9.5c1.2-1.2,3.2-1.2,4.4,0c1.2,1.2,1.2,3.2,0,4.4l-9.5,9.5c-0.1,0.1-0.3,0.2-0.5,0.3l-4,1C8.2,17,8.1,17,8,17zM9.9,12.5l-0.5,2.1l2.1-0.5l9.3-9.3c0.4-0.4,0.4-1.1,0-1.6c-0.4-0.4-1.2-0.4-1.6,0l0,0L9.9,12.5z M18.5,2.5L18.5,2.5L18.5,2.5z"></path></svg> 在 Gitee 上编辑此页<!--]--></a></div><div class="last-updated" data-v-fa7cebd8><p class="VPLastUpdated" data-v-fa7cebd8 data-v-98117fc8>Last updated: <time datetime="2023-10-23T08:35:22.000Z" data-v-98117fc8></time></p></div></div><nav class="prev-next" data-v-fa7cebd8><div class="pager" data-v-fa7cebd8><a class="pager-link prev" href="/init/project-config/vue/src.html" data-v-fa7cebd8><span class="desc" data-v-fa7cebd8>Previous page</span><span class="title" data-v-fa7cebd8>Src别名设置</span></a></div><div class="pager" data-v-fa7cebd8><a class="pager-link next" href="/init/project-config/vue/prettier.html" data-v-fa7cebd8><span class="desc" data-v-fa7cebd8>Next page</span><span class="title" data-v-fa7cebd8>Prettier配置</span></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-71011c1a data-v-fda2f082><div class="container" data-v-fda2f082><p class="message" data-v-fda2f082>Released under the <a href="https://github.com/vuejs/vitepress/blob/main/LICENSE">MIT License</a>.</p><p class="copyright" data-v-fda2f082>Copyright © 2019-present <a href="https://github.com/yyx990803">Evan You</a></p></div></footer><!--[--><!--]--></div></div>
    <script>window.__VP_HASH_MAP__=JSON.parse("{\"project-config_uniapp_uniui.md\":\"56866ea6\",\"project-config_react_create.md\":\"51b7231a\",\"project-config_uniapp_husky.md\":\"6ac09324\",\"project-config_vue_constraint.md\":\"0a6bf6ec\",\"index.md\":\"b8b99956\",\"project-config_vue_scss.md\":\"a57ef0ed\",\"project-config_vue_create.md\":\"7eceaa7a\",\"project-config_uniapp_env.md\":\"a82cd6e0\",\"project-config_uniapp_prettier.md\":\"6c5672cd\",\"project-config_vue_commitlint.md\":\"4a71a876\",\"project-config_uniapp_pinia.md\":\"51c68e1e\",\"project-config_vue_husky.md\":\"cd5d297a\",\"project-config_vue_src.md\":\"1ccc5ade\",\"project-config_vue_axios.md\":\"11786a11\",\"project-config_uniapp_create.md\":\"396e7eba\",\"project-config_uniapp_subpackage.md\":\"0ea1ae98\",\"project-config_vue_env.md\":\"ed742da2\",\"project-config_uniapp_commitlint.md\":\"96fcbd13\",\"project-config_vue_proxy.md\":\"f035ab37\",\"project-config_uniapp_interceptor.md\":\"e2dc864f\",\"project-config_uniapp_eslint.md\":\"892ff428\",\"skill_index.md\":\"51433267\",\"project-config_vue_pinia.md\":\"a6a6c967\",\"project-config_vue_svg.md\":\"d30f2d50\",\"start_index.md\":\"9798094d\",\"project-config_vue_prettier.md\":\"ad4e43a5\",\"project-config_vue_eslint.md\":\"b98da907\",\"project-config_vue_elementplus.md\":\"37b3aa26\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"zh-CN\",\"dir\":\"ltr\",\"title\":\"项目初始化环境配置\",\"titleTemplate\":\":title\",\"description\":\"A VitePress Site\",\"base\":\"/init/\",\"head\":[],\"appearance\":true,\"themeConfig\":{\"logo\":\"/vite.svg\",\"nav\":[{\"text\":\"开始\",\"link\":\"/start/index\",\"activeMatch\":\"/start/\"},{\"text\":\"项目环境配置\",\"items\":[{\"items\":[{\"text\":\"vue\",\"link\":\"/project-config/vue/create\"},{\"text\":\"uniapp\",\"link\":\"/project-config/uniapp/create\"},{\"text\":\"react\",\"link\":\"/project-config/react/create\"},{\"text\":\"react native\",\"link\":\"/project-config/react-native/create\"}]}]},{\"text\":\"小技巧\",\"link\":\"/skill/index\",\"activeMatch\":\"/skill/\"}],\"sidebar\":{\"/start/\":[{\"text\":\"开始\",\"collapsed\":false,\"items\":[{\"text\":\"前言\",\"link\":\"/start/index\"}]}],\"/project-config/vue/\":[{\"text\":\"vue\",\"collapsed\":true,\"items\":[{\"text\":\"创建项目\",\"link\":\"/project-config/vue/create\"},{\"text\":\"Element-Plus配置\",\"link\":\"/project-config/vue/elementPlus\"},{\"text\":\"环境变量别名设置\",\"link\":\"/project-config/vue/env\"},{\"text\":\"Axios的二次封装\",\"link\":\"/project-config/vue/axios\"},{\"text\":\"Scss变量自动导入\",\"link\":\"/project-config/vue/scss\"},{\"text\":\"Src别名设置\",\"link\":\"/project-config/vue/src\"},{\"text\":\"Eslint配置\",\"link\":\"/project-config/vue/eslint\"},{\"text\":\"Prettier配置\",\"link\":\"/project-config/vue/prettier\"},{\"text\":\"Husky配置\",\"link\":\"/project-config/vue/husky\"},{\"text\":\"Commitlint配置\",\"link\":\"/project-config/vue/commitlint\"},{\"text\":\"强制使用pnpm包管理工具\",\"link\":\"/project-config/vue/constraint\"},{\"text\":\"Svg图标的使用\",\"link\":\"/project-config/vue/svg\"},{\"text\":\"Proxy代理\",\"link\":\"/project-config/vue/proxy\"},{\"text\":\"Pinia持久化\",\"link\":\"/project-config/vue/pinia\"}]}],\"project-config/uniapp/\":[{\"text\":\"Uniapp\",\"collapsed\":true,\"items\":[{\"text\":\"创建项目\",\"link\":\"/project-config/uniapp/create\"},{\"text\":\"环境变量别名设置\",\"link\":\"/project-config/uniapp/env\"},{\"text\":\"Eslint配置\",\"link\":\"/project-config/uniapp/eslint\"},{\"text\":\"Prettier配置\",\"link\":\"/project-config/uniapp/prettier\"},{\"text\":\"Husky配置\",\"link\":\"/project-config/uniapp/husky\"},{\"text\":\"Commitlint配置\",\"link\":\"/project-config/uniapp/commitlint\"},{\"text\":\"安装uni-ui组件库\",\"link\":\"/project-config/uniapp/uniui\"},{\"text\":\"Pinia持久化\",\"link\":\"/project-config/uniapp/pinia\"},{\"text\":\"请求封装\",\"link\":\"/project-config/uniapp/interceptor\"},{\"text\":\"分包预加载\",\"link\":\"/project-config/uniapp/subpackage\"}]}],\"/skill/\":[{\"text\":\"小技巧\"}]},\"footer\":{\"message\":\"Released under the <a href=\\\"https://github.com/vuejs/vitepress/blob/main/LICENSE\\\">MIT License</a>.\",\"copyright\":\"Copyright © 2019-present <a href=\\\"https://github.com/yyx990803\\\">Evan You</a>\"},\"editLink\":{\"pattern\":\"https://gitee.com/HikJ/vitepress-template\",\"text\":\"在 Gitee 上编辑此页\"},\"search\":{\"provider\":\"local\"},\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://gitee.com/HikJ\"},{\"icon\":{\"svg\":\"\"},\"link\":\"...\"}]},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":false}");</script>
    
  </body>
</html>